package cn.wolfcode.p2p.base.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
@Setter
@Getter
public class IpLog extends BaseDomain {
    //登录成功
    public static final int LOGIN_STATE_SUCCESS = LoginInfo.STATE_NORMAL;
    //登录失败
    public static final int  LOGIN_STATE_FAIL = LoginInfo.STATE_LOCK;
    //登录的ip
    private String ip;
    //登录的状态
    private Integer state = LOGIN_STATE_SUCCESS;
    //登录的用户名
    private String username;
    //登录的时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginTime;

    private Integer userType = LoginInfo.TYPE_WEBSITE;

    /**
     * 登陆状态的名字
     */
    public String getStateName(){
        return state == LOGIN_STATE_SUCCESS ? "登陆成功":"登陆失败";
    }
    /**
     * 登陆用户类型的名字
     */
    public String getUserTypeName(){
        return userType == LoginInfo.TYPE_WEBSITE? "前台用户":"后台用户";
    }

}